package com.example.producerandconsumer.blockingqueue;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class Test {
    public static void main(String[] args) {
        BlockingQueue queue = new ArrayBlockingQueue(10);
        Producer producer1 = new Producer(queue, 1);
        Producer producer2 = new Producer(queue, 2);
        Producer producer3 = new Producer(queue, 3);
        Consumer consumer1 = new Consumer(queue, 1);
        Consumer consumer2 = new Consumer(queue, 2);
        Consumer consumer3 = new Consumer(queue, 3);
        ExecutorService service = Executors.newCachedThreadPool();
        service.submit(producer1);
        service.submit(producer2);
        service.submit(producer3);
        service.submit(consumer1);
        service.submit(consumer2);
        service.submit(consumer3);
    }
}
